package test.com.newproject.moudle.main.homepage;

import android.util.Log;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import library.com.httphelper.HttpHelper;
import test.com.newproject.framework.mvp.BasePresenter;
import test.com.newproject.model.beans.DataBean;

/**
 * Created by zjh on 2017/8/14.
 */

public class HomepagePresenter extends BasePresenter<IHomepageContract.IView> implements IHomepageContract.IPresenter {

    public static final String TAG = "HomepagePresenter";

    @Override
    public void requestData() {
        Log.d(TAG, "requestData: ");
        String url = "query";
        Map<String, String> map = new HashMap<>();
        map.put("type", "shentong");
        map.put("postid", "3356733167300");
        HttpHelper.DEFAULT.execute(new HttpHelper.Request<List<DataBean>>(url, map) {
            @Override
            public void onSuccess(List<DataBean> result) {
                Log.d(TAG, "onSuccess: " + result.get(0).getTime());
                iView.refreshData(result);
            }

            @Override
            public void onError(int code, String err) {
                super.onError(code, err);
                Log.d(TAG, "onError: " + err);
                iView.requestFailed(err);
            }
        });
    }
}
